﻿using University.Workshop.DataAccess;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using University.Workshop.Business;
using University.Workshop.Model;

namespace University.Workshop.Tests
{
    
    
   
    [TestClass()]
    public class ClientDataAccessTest
    {


        private TestContext testContextInstance;

        
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        
        [TestMethod()]
        public void RegisterClientTest()
        {
            Random ran = new Random();
            int num = ran.Next(10000);
            Client client = new Client()
            {
                Nit=num.ToString(System.Globalization.CultureInfo.CurrentCulture),
                Name="Luis",
                FatherLastName="Ramallo",
                MotherLastName="Gonzales",
                Phone="4687765",
                CellPhone="70789898",
                Address="Av. Ayacucho",
                Email="luis@hotmail.com",
                State="A"
            };
            bool actual = ClientDataAccess.RegisterClient(client);
            Assert.IsTrue(actual);
        }

        
        [TestMethod()]
        public void ReviewIdIfNitRegisterTest()
        {
            string nit = "101010"; 
            bool expected = false; 
            bool actual;
            actual = ClientDataAccess.ReviewIdIfNitRegister(nit);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void RegisterClientTestEmpty()
        {
            Client client = new Client()
            {
                Nit = string.Empty,
                Name = "Luis",
                FatherLastName = "Ramallo",
                MotherLastName = "Gonzales",
                Phone = "4687765",
                CellPhone = "70789898",
                Address = "Av. Ayacucho",
                Email = "luis@hotmail.com",
                State = "A"
            };
            bool actual = ClientDataAccess.RegisterClient(client);
            Assert.IsTrue(actual);
        }

        [TestMethod()]
        [ExpectedException(typeof(BusinessException))]
        public void RegisterClientNullTest()
        {
            Client client = null; 
            bool actual;
            actual = ClientDataAccess.RegisterClient(client);
        }

        [TestMethod()]
        public void DeleteClientDataTest()
        {
            string value = "111"; 
            bool expected = true; 
            bool actual;
            actual = ClientDataAccess.DeleteClientData(value);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        public void ModifyAddressClientTestTrue()
        {
            string value = "mi casa"; 
            string nit = "245"; 
            bool expected = true; 
            bool actual;
            actual = ClientDataAccess.ModifyAddressClient(value, nit);
            Assert.AreEqual(expected, actual);
        }
    }
}
